package com.ysx.oa.teacher.controller;





import com.ysx.oa.teacher.bean.TeacherBean;
import com.ysx.oa.teacher.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private TeacherService service;

    // http://localhost:8080/kaoqin/role/find.do?id=800200
    @RequestMapping(value="/find.do",method = RequestMethod.GET)
    public Map<String,Object> findById(Integer id){
        Map<String,Object> map = new HashMap();

        TeacherBean bean=null;
        try{
            bean = service.findById(id);
        }catch (Exception exception){
            System.out.println(exception);
        }

        map.put("code",200);
        map.put("message","success");
        map.put("data",bean);
        return map;
    }

    @RequestMapping(value = "/add.do",method = RequestMethod.POST)
    public Map<String,Object> add(@RequestBody TeacherBean bean){
        Map<String,Object> map = new HashMap();
        service.add(bean);

        map.put("code",200);
        map.put("message","success");
        map.put("data",null);
        return map;
    }

}
